/**
 * 
 * 
 */
package com.wistech.solr.ik;

import java.io.Reader;
import java.util.Map;


import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.util.TokenizerFactory;
import org.wltea.analyzer.lucene.IKTokenizer;

/**
 * IK中文分词 Solr分词器工厂实现
 * 
 * 2012-3-6
 * 
 */
public class IKTokenizerFactory extends TokenizerFactory {

	private boolean useSmart = false;

	@Override
	public void init(Map<String, String> params) {
		super.init(params);
		String useSmartParam = params.get("useSmart");
		this.useSmart = (useSmartParam != null ? Boolean
				.parseBoolean(useSmartParam) : false);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.apache.solr.analysis.TokenizerFactory#create(java.io.Reader)
	 */
	public Tokenizer create(Reader in) {
		return new IKTokenizer(in, this.useSmart);
	}

}
